home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / gfx / edit / AmiCAD_2.06.lha / AmiCAD / ARexx / Cartouche.amiCAD < prev    next >
Text File  |  2000-04-13  |  4KB  |  161 lines

  1. /* Script ARexx permettant le tracé d'un cartouche dans une fenêtre AmiCAD */
  2. /* Chez Corbin, Vendredi 3 Octobre 1997, Version 1.00, © R.Florac */
  3. /* Version 1.01, 2 Novembre 1997, trait vertical rajouté dans cartouche */
  4. /* Version 1.02, 23 janvier 1998, ajout titre, date, etc... */
  5. /* Version 1.03, 12 février 1998, test longueurs chaînes pour ajustement largeur */
  6. /* Version 1.04, 24 mai 1998, test présence rexxlocaldates.library */
  7. /* Version 1.05, 21 juin 1998, ajout test après choix emplacement cartouche pour arrêt */
  8. /* Version 1.06, 14 juillet 1998, modification tracé lignes (lignes quelconques) */
  9. /* Version 1.06a, 15 janvier 1999, remplacement fonction ASK par ASKTEXT */
  10. /* Version 1.07, 13 avril 2000, modification fonctions SAVEALL, WWIDTH, WHEIGHT, ajout SETSCALE */
  11. /* $VER: Cartouche.AmiCAD 1.07 (© R.Florac, 13/04/00) */
  12.  
  13. options results
  14.  
  15. organisation="LYCÉE Bernard PALISSY SAINTES"
  16. signal on error
  17. signal on syntax
  18.  
  19. if (~show('L','rexxlocaldates.library')) then
  20.   call addlib('rexxlocaldates.library',0,-30,0)
  21.  
  22. if (show('L','rexxlocaldates.library')) then do
  23.     Ib = OpenLocale()
  24.     jour = FormatDate(Ib, ,"%A %e %B %Y")
  25. end
  26. else do
  27.     'DATE(1)'; jour=result
  28. end
  29.  
  30. 'WWIDTH'; l = result; lc = result % 3
  31. 'WHEIGHT'; h =result
  32. 'ROTATE(0,0):SYMMETRY(0,0):SETSCALE(0,100,100)'
  33.  
  34. 'SELECT("Emplacement du cartouche"+CHR(10)+"En haut à gauche"+CHR(10)+"En haut à droite"+CHR(10)+"En haut au centre"+CHR(10)+"En bas au centre"+CHR(10)+"En bas à droite"+CHR(10)+"En bas à gauche")'
  35. c = result
  36. if c<1 then exit    /* Version 1.05 */
  37.  
  38. 'ASKTEXT("Titre du cartouche","")'; titre = result
  39. if titre='' then exit
  40.  
  41. if lc<260 then lc=260
  42. 'TXWIDTH("'organisation'")'; lt = result
  43. if lt>lc-10 then lc=lt+10
  44. 'TXWIDTH("'titre'")'; lt = result
  45. if lt>lc-10 then lc=lt+10
  46. dx=(lc+5)%4*3
  47. 'TXWIDTH("'jour'")'; lt = result
  48. if lt>dx-10 then do
  49.     dx=lt+10
  50.     lc=dx%3*4
  51. end
  52.  
  53. select
  54.     when c = 1 then do        /* En haut à gauche */
  55.     x0 = 5
  56.     x1 = lc + 5
  57.     y0 = 5
  58.     y1 = 85
  59.     bh = 0
  60.     bb = 1
  61.     bg = 0
  62.     bd = 1
  63.     end
  64.     when c = 2 then do        /* En haut à droite */
  65.     x0 = l - lc - 5
  66.     x1 = l - 5
  67.     y0 = 5
  68.     y1 = 85
  69.     bh = 0
  70.     bb = 1
  71.     bg = 1
  72.     bd = 0
  73.     end
  74.     when c = 3 then do        /* En haut au centre */
  75.     x0 = l % 2 - lc % 2
  76.     x1 = x0 + lc
  77.     y0 = 5
  78.     y1 = 85
  79.     bh = 0
  80.     bb = 1
  81.     bg = 1
  82.     bd = 1
  83.     end
  84.     when c = 4 then do        /* En bas au centre */
  85.     x0 = l % 2 - lc % 2
  86.     x1 = x0 + lc
  87.     y0 = h - 85
  88.     y1 = h - 5
  89.     bh = 1
  90.     bb = 0
  91.     bg = 1
  92.     bd = 1
  93.     end
  94.     when c = 6 then do        /* En bas à gauche */
  95.     x0 = 5
  96.     x1 = 5 + lc
  97.     y0 = h - 85
  98.     y1 = h - 5
  99.     bh = 1
  100.     bb = 0
  101.     bg = 0
  102.     bd = 1
  103.     end
  104.     when c = 5 then do        /* En bas à droite */
  105.     x0 = l - lc - 5
  106.     x1 = l - 5
  107.     y0 = h - 85
  108.     y1 = h - 5
  109.     bh = 1
  110.     bb = 0
  111.     bg = 1
  112.     bd = 0
  113.     end
  114.     otherwise exit
  115. end
  116.  
  117. /* sauvegarde du contexte, dessin du contour */
  118. 'SAVEALL:DRAWMODE(-2):DRAW(5,5,'l-5',5):DRAW('l-5',5,'l-5','h-5')'
  119. 'DRAW('l-5','h-5',5,'h-5'):DRAW(5,'h-5',5,5)'
  120.  
  121. /* Tracé du bord horizontal haut */
  122. if bh > 0 then 'DRAW('x0','y0','x1','y0')'
  123. /* Tracé du bord horizontal bas */
  124. if bb > 0 then 'DRAW('x0','y1','x1','y1')'
  125. /* Tracé du bord vertical gauche */
  126. if bg > 0 then 'DRAW('x0','y0','x0','y1')'
  127. /* Tracé du bord vertical droit */
  128. if bd > 0 then 'DRAW('x1','y0','x1','y1')'
  129. /* Tracé des lignes horizontales intermédiaires */
  130. 'DRAW('x0','y0+20','x1','y0+20')'
  131. 'DRAWMODE(-1):DRAW('x0','y0+40','x1','y0+40'):DRAW('x0','y0+60','x1','y0+60')'
  132. /* Tracé de la ligne verticale intermédiaire */
  133. 'DRAW('dx+x0','y0+40','dx+x0','y1')'
  134.  
  135. 'SETSCALE(0,100,100)'
  136. call centrer_texte(organisation,x0,x1,y0+15)
  137. call centrer_texte(titre,x0,x1,y0+35)
  138. call centrer_texte(jour,x0,x0+dx,y0+75)
  139. call centrer_texte("Document Numéro 1/1",x0,x0+dx,y0+55)
  140. call centrer_texte("REV 1",x0+dx,x1,y0+55)
  141. call centrer_texte("AmiCAD",x0+dx,x1,y0+75)
  142.  
  143. exit
  144.  
  145. centrer_texte: procedure
  146.     parse arg texte, xg, xd, y
  147.     'TXWIDTH("'texte'")'; l = result
  148.     l = (xd-xg-l)%2
  149.     'WRITE("'texte'",'xg+l','y')'
  150.     return
  151.  
  152. /* Traitement des erreurs, interruption du programme */
  153. syntax:
  154. erreur=RC
  155. 'MESSAGE("Script Cartouche.AmiCAD:"+CHR(10)+"Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  156. exit
  157.  
  158. error:
  159. 'MESSAGE("Script Cartouche.AmiCAD:"+CHR(10)+"Erreur en ligne 'SIGL'")'
  160. exit
  161.